/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package runner;

import com.jme.image.Texture;
import com.jme.input.MouseInput;
import com.jme.renderer.Renderer;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.GameTaskQueueManager;
import com.jme.util.TextureManager;
import com.jmex.awt.swingui.JMEDesktopState;
import com.jmex.game.state.BasicGameState;
import com.jmex.game.state.GameStateManager;
import java.awt.Color;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Callable;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

//import sun.reflect.generics.tree.BottomSignature;

/**
 *
 * @author yamit_alejandro
 */
public class Creditos extends JMEDesktopState {


    private final int INICIOX = 350;
    private final int INICIOY = 240;
    private JLabel mTitulo = null;
    private JButton mElegir = null;
    private JButton mEsgrima = null;
    private JButton mSalir = null;
    private JButton mVolverPpal = null;
    private JButton mOpciones = null;
    private JButton mBalineras = null;
    private JButton mCreditos = null;
    private boolean mEffect = true;
    private JButton mAtras = null;
    private JTextArea mText = null;
    private JTextArea mTextoCreditos = null;
    private JScrollPane mScroll = null;
    private final Color B_COLOR = Color.white;
    private final Color T_COLOR = Color.black;
    private final Dimension B_DIMENSION = new Dimension(200, 25);
    private final Font T_FUENTE = new Font(Font.SANS_SERIF, Font.BOLD, 28);
    private boolean credits = false;
    private BasicGameState mBackground = null;
    private Quad mFondo = null;
    private EscenaPrincipal mRoot;
    private JButton mJugar = null;
    private MainMenuState padre;

 public Creditos () {
    ponerFondo("imagenes/menuPrincipal.jpg");


        GameTaskQueueManager.getManager().update(new Callable<Void>() {

            public Void call() throws Exception {
                SwingUtilities.invokeAndWait(new Runnable() {

                    public void run() {

                        mostrarCreditos();
                    }
                });
                MouseInput.get().setCursorVisible(true);
                return null;
            }
        });

    }

private void ponerFondo(String imagen) {

        mFondo = new Quad("MainMenuBackground", 750, 600);
        mFondo.setRenderQueueMode(Renderer.QUEUE_ORTHO);
        int w = DisplaySystem.getDisplaySystem().getWidth();
        int h = DisplaySystem.getDisplaySystem().getHeight();


        mFondo.setLocalTranslation(w / 2, h / 2, 0);

        Texture mTexture = TextureManager.loadTexture(MainMenuState.class.getClassLoader().getResource(imagen));
        TextureState mTextureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
        mTextureState.setTexture(mTexture);
        mTextureState.setEnabled(true);
        mFondo.setRenderState(mTextureState);

        mFondo.setCullHint(Spatial.CullHint.Never);
        mFondo.setLightCombineMode(Spatial.LightCombineMode.Off);
        mFondo.updateRenderState();
        mFondo.updateGeometricState(0, true);

        mBackground = new BasicGameState("BasicGameState");
        GameStateManager.getInstance().attachChild(mBackground);
        mBackground.setActive(false);

        mBackground.cleanup();
        mBackground.getRootNode().attachChild(mFondo);
        mBackground.getRootNode().updateRenderState();



    }


 private void mostrarCreditos() {

        getDesktop().getJDesktop().removeAll();
        getDesktop().getJDesktop().repaint();


        mTitulo = new JLabel("Creditos");
        getDesktop().getJDesktop().add(mTitulo);
        mTitulo.setFont(T_FUENTE);
        mTitulo.setForeground(T_COLOR);
        mTitulo.setLocation(INICIOX, INICIOY);
        mTitulo.setSize(mTitulo.getPreferredSize());


        String nombres = "Criollolimpicos es un juego hecho en Colombia\n" +
                "por las casas desarrolladoras:\n" +
                "\n" +
                "WHITE WALL\n" +
                "MARÍA DEL MAR MUÑOZ MARTÍNEZ (Diseñadora)\n" +
                "JULIO CÉSAR CHÁVES FERNÁNDEZ (Lider Técnico)\n" +
                "DANIEL AUGUSTO AMARILES GARCÍA (Programador)\n" +
                "DIEGO FERNANDO ARIAS ALMEIDA (Programador)\n" +
                "\n" +
                "VALLEY ARTS\n" +
                "JUAN FERNANDO ADARVE CARVALLO (Diseñador)\n" +
                "YAMIT ALEJANDRO HUERTAS PARRA(Lider Técnico)\n" +
                "JUAN CARLOS GÓMEZ RUIZ(Programador)";

        mTextoCreditos = new JTextArea(nombres, 7, 1);
        getDesktop().getJDesktop().add(mTextoCreditos);
        mTextoCreditos.setSize(new Dimension(400, 220));
        mTextoCreditos.setLocation(INICIOX, INICIOY + 50);
        mTextoCreditos.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 12));
        mTextoCreditos.setForeground(T_COLOR);
        mTextoCreditos.setEditable(false);
        mTextoCreditos.setBackground(new Color(0, 0, 0, 0));
        mTextoCreditos.setAutoscrolls(true);


        mVolverPpal = new JButton("Volver al menu principal");
        getDesktop().getJDesktop().add(mVolverPpal);
        mVolverPpal.setLocation(INICIOX, INICIOY + 270);
        mVolverPpal.setBackground(B_COLOR);
        mVolverPpal.setSize(B_DIMENSION);
        mVolverPpal.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                 setActive ( false );
                 mBackground.setActive(false);
                 padre.setActive(true);
                 padre.getBackground().setActive(true);
            }
        });


    }



     public void setControlPrincipal ( MainMenuState root )
    {
        padre = root;
    }
     public BasicGameState getBackground (  )
    {
        return mBackground;
    }


}